package com.gxa.controller;

import com.gxa.common.JsonResult;
import com.gxa.common.PageRecv;
import com.gxa.common.R;
import com.gxa.pojo.Recycle;
import com.gxa.service.RecycleService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

//转回或还原要删除对应的回收站信息
@Controller
@RequestMapping(value = "/recycle")
@Api(value = "回收站数据test",tags = "回收站数据接口API-周军国")
public class RecycleController {
    @Autowired
    private RecycleService recycleService;
    @RequestMapping(value = "/addRecycle",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "回收站添加接口",notes = "向数据库添加删除的客户信息",httpMethod = "post", response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R addRecycle(@RequestBody @ApiParam(name = "recycle",value = "存储删除客户页面的数据信息",required = true) Recycle recycle){
        R r=new R();
        System.out.println(recycle.toString());
        r=recycleService.addRecycle(recycle);
        System.out.println("添加接口的接收数据"+recycle);
        return  r;
    }
    @RequestMapping(value = "/selectRecycle",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "回收站查询接口",notes = "查询数据库中属于回收站的客户信息,支持无条件查询和按时间段查询",httpMethod = "post", response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public JsonResult selectRecycle(@RequestBody @ApiParam(name = "pageRecv",value = "存储查询回收站页面的数据信息",required = true)PageRecv<Recycle> pageRecv){
        JsonResult r=new JsonResult();
        System.out.println(pageRecv.getCurrentPage());
        System.out.println(pageRecv.getPageSize());
        r=recycleService.selectRecycle(pageRecv);
        return r;
    }
    @RequestMapping(value = "/deleteRecycle",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "回收站删除接口",notes = "支持单条、批量彻底删除和清空回收站",httpMethod = "post", response = R.class)
    @ApiImplicitParam(name = "recycleids",value = "集合接收回收站数据id",paramType = "query",dataType = "Integer", allowMultiple = true,required = false)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R deleteRecycle(@RequestParam List<Integer> recycleids){
        System.out.println("成功进入");
        R r=new R();
     r=recycleService.deleteRecycle(recycleids);
        System.out.println("删除接口的返回数据"+recycleids.toString());
    return r;
    }
    @RequestMapping(value = "/deleteAllRecycle",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "清空回收站接口",notes = "支持清空回收站",httpMethod = "post", response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R deleteAllRecycle(){
        R r=new R();
        return r;
    }
    @RequestMapping(value = "/searchRecycle",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "回收站搜索接口",notes = "查询数据库中属于回收站的客户信息,支持普通搜索框",httpMethod = "post", response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public JsonResult searchRecycle(@RequestBody @ApiParam(name = "pageRecv",value = "存储查询回收站页面的数据信息",required = true)PageRecv<Recycle> pageRecv){
        JsonResult jsonResult=new JsonResult();
        jsonResult=recycleService.searchRecycle(pageRecv);
        return jsonResult;

    }
//还原以批量还原
@RequestMapping(value = "/reduction",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "客户还原",notes = "支持还原以及批量还原",httpMethod = "post", response = R.class)
@ApiResponses({
        @ApiResponse(code=200,message="请求成功"),
        @ApiResponse(code=404,message="找不到页面"),
        @ApiResponse(code=500,message="后台服务错误")
})
    public R reduction(@RequestParam List<Integer> recycleids){
        R r=new R();
        r=recycleService.reduction(recycleids);
        return r;
    }
    ///移入公海以及批量移入公海
    @RequestMapping(value = "/transfer",method = RequestMethod.POST)
    @ResponseBody
    @ApiOperation(value = "移入公海",notes = "支持移入公海以及批量移入公海",httpMethod = "post", response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    public R transfer(@RequestParam List<Integer> recycleids){
        R r=new R();
        r=recycleService.transfer(recycleids);
        return r;
    }
}
